package org.jimmy.tang.ssm.action;

import java.util.ArrayList;
import java.util.List;

public class TestAction extends BaseAction {

	private static final long serialVersionUID = 1L;

	public String getName() {
		return "Jimmy - 1";
	}

	/**
	 * 
	 * @return
	 */
	public String test() {
		return SUCCESS;
	}

	/**
	 * 
	 * @return
	 */
	public String toIterator() {
		return SUCCESS;
	}

	public List<String> getNames() {
		List<String> names = new ArrayList<String>();
		for (int i = 1; i < 6; i++) {
			String name = "name : " + i;
			names.add(name);
		}
		return names;
	}

	/**
	 * 
	 * @return
	 */
	public List<Person> getPersons() {
		List<Person> persons = new ArrayList<Person>();
		for (int i = 1; i < 5; i++) {
			Person pn = new Person();
			pn.setAge(String.valueOf(i));
			pn.setGender(i % 2 == 0 ? "male" : "female");
			persons.add(pn);
		}
		return persons;

	}

	class Person {
		String age;
		String gender;

		public String getAge() {
			return age;
		}

		public void setAge(String age) {
			this.age = age;
		}

		public String getGender() {
			return gender;
		}

		public void setGender(String gender) {
			this.gender = gender;
		}

	}

}
